package com.oros.db;

import java.io.Serializable;

import com.vaadin.data.Item;
import com.vaadin.data.Container.Filter;

import com.vditl.core.*;

public class AEMultiEqualFilter implements Serializable, Filter {

	private static final long serialVersionUID = 1L;
	private UniVector columnMap;
	
    public AEMultiEqualFilter(UniVector columnMap)
    {
       this.columnMap = columnMap;	
    }
	@Override
	public boolean passesFilter(Object itemId, Item item)
			throws UnsupportedOperationException {
		int n = columnMap.size();
		AERawItem aeitem = (AERawItem)item;
		for(int i=0;i<n;i++)
		{
			LongElement elem = ((LongElement)columnMap.get(i));
			int colNo =(int) elem.getLong();
			Object val = elem.getValue();
			Object realVal = aeitem.getColumnValue(colNo);
			if (val==realVal) continue;
			if (val==null || realVal==null || !val.equals(realVal)) return false;
		}
		return true;
	}

	@Override
	public boolean appliesToProperty(Object propertyId) {
		return true;
	}

}
